class Solution(object):
    def findNthDigit(self, n):
        """
        :type n: int
        :rtype: int
        """
        i = 1
        def foo(i):
            return i*9*(10**(i-1))
        while n>foo(i):
            n-=foo(i)
            i+=1
        n-=1
        digit = 10**(i-1)+(n//i)
        digit = list(str(digit))
        return int(digit[n%i])
print(Solution().findNthDigit(3))